package com.dinnerorders.web.helpers;

import com.dinnerorders.web.enums.MessageCode;
import org.springframework.context.support.AbstractMessageSource;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Locale;

public class MessageHelper {

    private static final AbstractMessageSource messageSource =
            (AbstractMessageSource) new ClassPathXmlApplicationContext("web-beans.xml").getBean("messageResource");

    public static String getMessage(MessageCode code) {
        return messageSource.getMessage(code.getCode(), null, Locale.US);
    }
}
